package club.xcgame520.okhttp;

import android.content.Context;
import android.util.Log;

import org.json.JSONObject;

import java.util.Map;

/**
 * 下载文件请求回调
 * <br/>
 * Created by 小灿 on 2016/11/14.
 */
public class UploadResponseCallback {

    private Context context;
    private String url;

    public String getUrl() {
        return url;
    }

    protected void setUrl(String url) {
        this.url = url;
    }

    public Context getContext() {
        return context;
    }

    protected void setContext(Context context) {
        this.context = context;
    }

    public void onStart() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传开始：" + url);
        }
    }


    public void onFailure(Map<String,Object> responseMap) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传失败：" + new JSONObject(responseMap));
        }
    }

    public void onSuccess(Map<String,Object> responseMap) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传成功：" + new JSONObject(responseMap));
        }
    }

    public void onCancel() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传取消：" + url);
        }
    }

    public void onFinish() {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传结束：" + url);
        }
    }

    public void onProgress(int progress, String paramKey, String fileName) {
        if (OkHttp.isPrintLog) {
            Log.d(OkHttp.TAG, "文件上传进度：" + progress + "，" + paramKey + "，" + fileName);
        }
    }
}
